package cn.cau.epidemicsurveysystem.service.impl;

import cn.cau.epidemicsurveysystem.service.DiseaseDataService;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * @projectName: gp2022
 * @package: cn.cau.epidemicsurveysystem.service.impl
 * @className: DiseaseDataServiceImpl
 * @author: zfy
 * @description: TODO
 * @date: 2022/3/7 0007 16:25
 * @version: 1.0
 */
@Service
public class DiseaseDataServiceImpl implements DiseaseDataService {
    @Autowired
    RestTemplate restTemplate;

    @Override
    public JSONObject getDiseaseData() {
        String url="https://c.m.163.com/ug/api/wuhan/app/data/list-total";
        String result = restTemplate.getForObject(url, String.class);
        System.out.println(result);
        JSONObject answersJson= JSON.parseObject(result);
        return answersJson;
    }

    @Override
    public JSONObject getDiseaseHistoryData() {
        String url="https://api.inews.qq.com/newsqa/v1/query/pubished/daily/list?province=北京";
        String result = restTemplate.getForObject(url, String.class);
        System.out.println(result);
        JSONObject answersJson= JSON.parseObject(result);
        return answersJson;
    }

}
